define([
	'../libs/zepto',
    '../common/dialog',
    '../common/ajax',
    '../common/storage',
    '../common/userAction',
    '../common/yingSoftPrg',
    '../common/yingSoftCookie'
],function(){
	var G_cpmArrNodes = [];
	var G_cpmArrTitle = [];
	var TestNum = 0;
	var G_cpmArrData = [];
	var IsVip = false;
	var IsRead = false;
	
	init();
	
	function init() {
		G_UserAction.loadObject();
		$('.back').click(function() {
			backClick();
		});
		if(G_Prg.$('examMode')) {
			G_Prg.$('examMode').onclick = function() {
			IsRead = true;
			G_Prg.$('examMode').style.display = 'none';
			G_Prg.$('readMode').style.display = 'block';
			}
		}
		if(G_Prg.$('readMode')) {
			G_Prg.$('readMode').onclick = function() {
			IsRead = false;
			G_Prg.$('readMode').style.display = 'none';
			G_Prg.$('examMode').style.display = 'block';
			}
		}
		var userID = G_Cookie.getUserID();
		var isRead = G_Prg.getQueryString('isRead');
		if(G_Prg.$('readMode') && G_Prg.$('examMode')) {
			if(isRead === '1') {
				IsRead = true;
				G_Prg.$('readMode').style.display = 'block';
			} else {
				G_Prg.$('examMode').style.display = 'block';
				}
			}
	        var curMenu = [];
			if(getChapterMenuData().length > 0) {
				curMenu = getChapterMenuData()[0].Childs;
			}
			if(userID) {
				if(typeof(G_ChapterCache) !== 'undefined') {
					G_cpmArrData = G_ChapterCache.getChapterInfo();
				}
				IsVip = G_Prg.checkVipApp();
			}
			var appEName = G_Cookie.getAppEName();
			var appENameArr = {
				'ZC_FC_YTMJ': true,
				'ZC_GWK_YTMJ': true,
				'ZC_MZ_YTMJ': true,
				'ZC_NK_YTMJ': true,
				'ZC_ZYNK_YTMJ': true,
				'ZC_ZGHS_YTMJ': true,
				'ZC_ZGHSEKHL_YTMJ': true,
				'ZC_ZGHSFKHL_YTMJ': true,
				'ZC_ZGHSSQHL_YTMJ': true,
				'ZC_ZGHSNKHL_YTMJ': true,
				'ZC_ZGHSWKHL_YTMJ': true,
				'ZC_YJSHI_YTMJ': true,
				'ZC_YJS_YTMJ': true,
				'ZC_YS_YTMJ': true,
				'ZY_XY_YTMJ': true,
				'ZY_ZYAO_YTMJ': true,
				'ZY_KQZY_YTMJ': true,
				'ZY_KQZL_YTMJ': true,
				'ZY_GWZY_YTMJ': true,
				'ZY_LCZY_YTMJ': true,
				'ZY_LCZL_YTMJ': true,
				'ZY_ZXYZY_YTMJ': true,
				'ZY_ZXYZL_YTMJ': true,
				'ZY_ZYZY_YTMJ': true,
				'ZY_ZYZL_YTMJ': true,
				'ZC_FS_YTMJ': true,
				'ZC_KQ_YTMJ': true,
				'ZC_MZ_YTMJ': true,
				'ZC_KFYX_YTMJ': true,
				'ZC_HYX_YTMJ': true,
				'ZC_BLX_YTMJ': true,
				'ZC_LCYXJYX_YTMJ': true,
				'ZC_CSBYX_YTMJ': true,
				'ZC_ZLNKX_YTMJ': true,
				'ZC_ZLWKX_YTMJ': true,
				'ZC_ZLFSZLX_YTMJ': true,
				'ZC_JS_YTMJ': true,
				'ZC_ZY_YTMJ': true,
				'ZC_ZYFK_YTMJ': true,
				'ZC_ZYNK_YTMJ': true,
				'ZC_ZXYJHNKX_YTMJ': true,
				'ZC_ZYEK_YTMJ': true,
				'ZC_ZYZJ_YTMJ': true,
				'ZC_TNAM_YTMJ': true,
				'ZC_ZYPFXB_YTMJ': true,
				'ZC_ZYGSK_YTMJ': true,
				'ZC_ZYWK_YTMJ': true,
				'ZC_ZYGCK_YTMJ': true,
				'ZC_ZYYK_YTMJ': true,
				'ZC_ZYEBHK_YTMJ': true,
				'ZC_FYBJ_YTMJ': true,
				'ZC_JKJY_YTMJ': true,
				'ZC_ZXYJHWK_YTMJ': true,
				'ZC_ZXYJHGSK_YTMJ': true,
				'ZC_KQNK_YTMJ': true,
				'ZC_KQZJ_YTMJ': true,
				'ZC_KQXF_YTMJ': true,
				'ZC_KQHMWK_YTMJ': true,
				'ZC_TTX_YTMJ': true,
				'ZC_ZZYX_YTMJ': true,
				'ZC_GGWS_YTMJ': true,
				'ZC_JBKZ_YTMJ': true,
				'ZC_ZYBS_YTMJ': true,
				'ZC_NK_YTMJ': true,
				'ZC_QK_YTMJ': true,
				'ZC_HXNK_YTMJ': true,
				'ZC_NFM_YTMJ': true,
				'ZC_SJNK_YTMJ': true,
				'ZC_SNK_YTMJ': true,
				'ZC_XHNK_YTMJ': true,
				'ZC_XXGNK_YTMJ': true,
				'ZC_XYB_YTMJ': true,
				'ZC_WK_YTMJ': true,
				'ZC_GWK_YTMJ': true,
				'ZC_MNWK_YTMJ': true,
				'ZC_SJWK_YTMJ': true,
				'ZC_XRWK_YTMJ': true,
				'ZC_XXWK_YTMJ': true,
				'ZC_CRBX_YTMJ': true,
				'ZC_FSYLCMYX_YTMJ': true,
				'ZC_JHB_YTMJ': true,
				'ZC_ZYB_YTMJ': true,
				'ZC_FC_YTMJ': true,
				'ZC_EK_YTMJ': true,
				'ZC_YK_YTMJ': true,
				'ZC_EBYHK_YTMJ': true,
				'ZC_JSBX_YTMJ': true,
				'ZC_PFXBX_YTMJ': true,
				'ZC_SSWK_YTMJ': true,
				'ZC_ZXWK_YTMJ': true
			}
			if(!appEName) {
				G_Prg.alert('请先选择科目。', function() {
				location.href = '/switchMenu';
				});
				return;
			}
			if(appEName in appENameArr) {
				showLast();
				return;
			}
			getTestNum(curMenu, G_cpmArrData);
			G_cpmArrTitle.push('押题密卷');
			G_cpmArrNodes.push(curMenu);
			var fromUrl = G_Prg.getQueryString('fromUrl');
			if(fromUrl === 'doExam.html' || fromUrl === 'userLogin.html' || fromUrl === 'selectPrice.html' || fromUrl === 'fastLearn.html') {
				var cptID = parseInt(G_Cookie.getCptID());
				if(cptID) {
					setcpmArrNodes(cptID, curMenu);
					setTopChapterMenu(G_cpmArrNodes[G_cpmArrNodes.length - 1]);
				} else {
					G_Prg.throw('不能处理cptID：' + cptID);
				}
			} else {
				setTopChapterMenu(curMenu);
			}
		}
	
	function getTestNum(data, userInfo) {
		var testNum = 0;
		var doneNum = 0;
		var rightCount = 0;
		for(var i = 0; i < data.length; i++) {
			var curMenu = data[i];
			if(curMenu.NodeType === 'Chapter') {
				var cptInfo = getUserInfo(curMenu.ID, userInfo);
				curMenu.DoneNum = cptInfo.testCount;
				curMenu.RightCount = cptInfo.RightCount;
			} else {
				var menuInfo = getTestNum(curMenu.Childs, userInfo);
				curMenu.TestNum = menuInfo.TestNum;
				curMenu.DoneNum = menuInfo.DoneNum;
				curMenu.RightCount = menuInfo.RightCount;
			}
			testNum = testNum + curMenu.TestNum;
			doneNum = doneNum + curMenu.DoneNum;
			rightCount = rightCount + curMenu.RightCount;
		}
		if(doneNum > testNum) {
			testNum = doneNum;
		}
		var returnData = {
			"TestNum": testNum,
			"DoneNum": doneNum,
			"RightCount": rightCount
		};
		return returnData;
	}
	
	function getUserInfo(cptID, data) {
		var userInfo = {
			"testCount": 0,
			"RightCount": 0
		};
		for(var i = 0; i < data.length; i++) {
			if(data[i].CptID === cptID) {
				userInfo.testCount = data[i].testCount;
				userInfo.RightCount = data[i].RightCount;
				break;
			}
		}
		return userInfo;
	}
	
	function setcpmArrNodes(cptID, srcData) {
		for(var i = 0; i < srcData.length; i++) {
			srcName = srcData[i].Name;
			srcID = srcData[i].ID;
			sbjData = srcData[i].Childs;
			for(var j = 0; j < sbjData.length; j++) {
				sbjName = sbjData[j].Name;
				sbjID = sbjData[j].ID;
				cptData = sbjData[j].Childs;
				for(var k = 0; k < cptData.length; k++) {
					if(cptData[k].ID === cptID) {
						G_cpmArrNodes.push(sbjData);
						G_cpmArrNodes.push(cptData);
						G_cpmArrTitle.push(srcName);
						G_cpmArrTitle.push(sbjName);
						return;
					}
				}
			}
		}
	}
	
	function getChapterMenuData() {
		var appEName = G_Cookie.getAppEName();
		if(!appEName) {
			G_Prg.throw('程序运行错误，chapterMenu.getChapterMenuData: appEName = "' + appEName + '",获取数据出现异常！');
	}
	var curMenu = '';
	if(G_Storage.checkLocalStorageSupport()) {
		var chapterMenu = G_Storage.getLocalStorageValue('chapterMenuData');
	if(chapterMenu && appEName === chapterMenu.AppEName) {
		var updateTime = getChapterMenuUpdateTime(appEName);
		if(updateTime === chapterMenu.UpdateTime) {
			curMenu = JSON.parse(chapterMenu.Data).Childs;
			var tempArr = [];
			for(var i = 0; i < curMenu.length; i++) {
				if(curMenu[i].Name == '考前押题' || curMenu[i].Name == '学尔森押题密卷' || curMenu[i].Name == '押题密卷') {
						tempArr.push(curMenu[i]);
					}
				}
				return tempArr;
			}
		}
	}
	if(window.localStorage) {
		var cacheKey = 'chapterCache_' + G_Cookie.getAppID() + '_' + G_Cookie.getUserID();
		localStorage.setItem(cacheKey, null);
	}
	var chapterMenuData = loadChapterMenu(appEName);
	var chapterMenuJson = {
		"Data": chapterMenuData.ChapterMenuJson,
		"AppEName": appEName,
		"UpdateTime": chapterMenuData.ChapterMenuUpdateTime
	};
	curMenu = JSON.parse(chapterMenuData.ChapterMenuJson).Childs;
	if(G_Storage.checkLocalStorageSupport()) {
		G_Storage.setLocalStorageValue('chapterMenuData', chapterMenuJson);
	}
	var tempArr = [];
	for(var i = 0; i < curMenu.length; i++) {
		if(curMenu[i].Name == '考前押题' || curMenu[i].Name == '学尔森押题密卷' || curMenu[i].Name == '押题密卷') {
				tempArr.push(curMenu[i]);
			}
		}
		return tempArr;
	}
	
	function loadChapterMenu(appEName) {
		var chapterData = '';
		G_AjaxApi_Record.get('/api/chapterMenu/getChapterMenu/' + appEName, false, function(json) {
			var jsonData = JSON.parse(json);
			if(jsonData.status === 200) {
				chapterData = jsonData.data;
			} else if(jsonData.status === 300) {
				G_Prg.throw('程序运行错误！："' + jsonData.msg + '"！');
			} else if(jsonData.status >= 400 && jsonData.status < 500) {
			} else {
				G_Prg.throw('程序运行错误！："无法处理"！');
			}
			});
			return chapterData;
	}
	
	function getChapterMenuUpdateTime(appEName) {
		var updateTime = '';
	G_AjaxApi_Record.get('/api/chapterMenu/getChapterMenuUpdateTime/' + appEName, false, function(json) {
	var jsonData = JSON.parse(json);
	if(jsonData.status === 200) {
		updateTime = jsonData.data.ChapterMenuUpdateTime;
	} else if(jsonData.status === 300) {
		G_Prg.throw('程序运行错误！："' + jsonData.msg + '"！');
	} else if(jsonData.status >= 400 && jsonData.status < 500) {
	} else {
		G_Prg.throw('程序运行错误！："无法处理"！');
			}
		});
		return updateTime;
	}
	
	function loadChapterHistoryCptid(userID) {
		var appEName = G_Cookie.getAppEName();
		var appID = G_Cookie.getAppID();
		var arrData = '';
	if(!appEName || !userID) {
		G_Prg.throw('程序运行错误，loadChapterMenu: appEName = "' + appEName + '","userID = "' + userID + '",获取数据出现异常！');
	}
	var url = '/api/chapterMenu/getCptIDNew?appID=' + appID + '&userID=' + userID + '&guid=' + G_Cookie.getGuid();
	G_AjaxApi_Record.get(url, false, function(json) {
		var jsonData = JSON.parse(json);
		if(jsonData.status === 200 || jsonData.status === 201) {
			arrData = jsonData.data;
		} else if(jsonData.status === 300) {
			G_Prg.throw('程序运行错误！："' + jsonData.msg + '"！');
	} else if(jsonData.status >= 400 && jsonData.status < 500) {
	} else {
		G_Prg.throw('程序运行错误！："无法处理"！');
			}
		});
		return arrData;
	}
	
	function showLast() {
		$('.title').html('押题密卷');
		G_Prg.$('Source').innerHTML = '';
		G_Prg.$('Source_last').innerHTML = '';
		var liTag = document.createElement('li');
		liTag.innerHTML = '押题密卷将于考前半个月陆续更新<br>敬请期待！';
		liTag.className = 'InternalData';
		G_Prg.$('Source_last').appendChild(liTag);
	}
	
	function setTopChapterMenu(curMenu) {
		if(!curMenu) {
			return;
		}
		G_Prg.$('back').innerHTML = G_cpmArrTitle[G_cpmArrTitle.length - 1];
		G_Prg.$('Source').innerHTML = '';
		G_Prg.$('Source_last').innerHTML = '';
		var arrData = G_cpmArrData;
		for(var i = 0; i < curMenu.length; i++) {
			var item = curMenu[i];
			if(item.Name === '知识点试题') {
			continue;
		}
		var spanTag = document.createElement('span');
		spanTag.innerHTML = item.Name;
		var liTag = document.createElement('li');
		liTag.id = i;
		if(item.Childs) {
			liTag.onclick = function() {
				menuClick(this.id);
			}
			liTag.className = 'chapter_fix1';
			if(item.DoneNum > 0) {
				spanTag.className = 'text_span5';
			} else {
				spanTag.className = 'text_span';
			}
			liTag.appendChild(spanTag);
			G_Prg.$('Source').appendChild(liTag);
		} else {
			var divTag = document.createElement('div');
			divTag.className = 'menudiv2';
			divTag.onclick = function() {
				menuClick(this.parentNode.id);
			}
			var brTag = document.createElement('br');
			var moerSpanTag = document.createElement('span');
			moerSpanTag.className = "fubiao";
			var Count = 0;
			var testCount = 0;
			var accuracy = '0.00';
			var answerPercentage = 0;
			if(arrData) {
				Count = item.TestNum;
				testCount = item.DoneNum;
				if(testCount !== 0) {
					divTag.onclick = function() {
						menuClick(this.parentNode.id, this.value);
					}
					accuracy = (item.RightCount / testCount * 100).toFixed(2);
					if(Count != 0) {
						answerPercentage = item.DoneNum / Count;
					} else {
						answerPercentage = 0;
					}
					if(testCount > item.TestNum) {
						testCount = item.TestNum;
					}
					var notDone = item.TestNum - testCount;
					if(notDone < 0) {
						notDone = 0;
					}
					divTag.value = notDone;
				}
			}
			var barProgress = document.createElement('div');
			barProgress.className = 'bar';
			var barText = document.createElement('div');
			var barValue = Number(testCount / item.TestNum * 100).toFixed(2);
			barText.innerHTML = barValue + '%';
			barText.className = 'bar-text';
			barProgress.appendChild(barText);
			var barDiv = document.createElement('div');
			barDiv.className = 'bar-bottom';
			var barDiv2 = document.createElement('div');
			barDiv2.className = 'bar-top';
			barDiv2.style.width = barValue + '%';
			barDiv.appendChild(barDiv2);
			barProgress.appendChild(barDiv);
			liTag.appendChild(barProgress);
			var imgdivTag = document.createElement('div');
			imgdivTag.id = item.ID;
			var notDoneNum = item.TestNum - testCount;
			if(notDoneNum < 0) {
				notDoneNum = 0;
			}
			imgdivTag.value = notDoneNum;
			imgdivTag.className = 'rightDiv';
			TestNum = item.TestNum;
			imgdivTag.onclick = function() {
				moerImgClick(this, this.value);
			}
			moerSpanTag.innerHTML = '<span class="num">共' + item.TestNum + '题</span>(已答' + testCount + '题&nbsp;&nbsp;&nbsp;正确率' + accuracy + '%)';
			divTag.appendChild(spanTag);
			divTag.appendChild(brTag);
			divTag.appendChild(moerSpanTag);
			liTag.className = 'chapter_fix2';
			liTag.appendChild(divTag);
			G_Prg.$('Source_last').appendChild(liTag);
			var arrClassNum = document.getElementsByClassName('num');
			if(arrClassNum[i]) {
				var tag = arrClassNum[i];
				tag.style.width = '60px';
				tag.style.paddingLeft = '0px';
				tag.style.paddingTop = '0px';
				tag.style.paddingRight = '5px';
				tag.style.marginLeft = '0px';
					}
				}
			}
		}
	
	function menuClick(arrIndex, notDoneNum) {
		var curMenu = G_cpmArrNodes[G_cpmArrNodes.length - 1];
		var sonMenu = curMenu[arrIndex].Childs;
		var cptID = curMenu[arrIndex].ID;
		var cptName = curMenu[arrIndex].Name;
		G_UserAction.addUserAction('selCptMenu_' + G_cpmArrTitle.length + '_' + cptName);
		if(sonMenu) {
			G_cpmArrTitle.push(cptName);
			G_cpmArrNodes.push(sonMenu);
			if(cptID === 'JC_EJJZS2') {
				showLast();
			} else {
				setTopChapterMenu(sonMenu);
			}
		} else {
			G_Cookie.setCptID(cptID);
			if(IsRead) {
				var url = 'fastLearn.html?fromUrl=yatiTest.html&cptName=' + encodeURI(cptName);
			pageJump(url);
			return;
		}
		var url = 'doExam.html?fromUrl=yatiTest.html&cptName=' + encodeURI(cptName);
				pageJump(url);
				return;
			}
		}
	
		function backClick() {
			if(G_cpmArrNodes.length === 1 || G_cpmArrNodes.length === 0) {
				window.location.href = '/doExam-index?fromUrl=ytmj';
			} else {
				G_cpmArrNodes.pop();
				G_cpmArrTitle.pop();
				var curMenu = G_cpmArrNodes[G_cpmArrNodes.length - 1];
				setTopChapterMenu(curMenu);
			}
		}
	
		function insertAfter(newElement, targetElement) {
			var parent = targetElement.parentNode;
			if(parent.lastChild == targetElement) {
				parent.appendChild(newElement);
			} else {
				parent.insertBefore(newElement, targetElement.nextSibling);
			}
		}
	
		function moerImgClick(obj, notDoneNum) {
			G_UserAction.addUserAction('cptInfoBtn');
			var s = document.getElementById(obj.id + '/liTag');
			if(s && s.style.display !== 'none') {
			obj.className = 'rightDiv';
			s.style.display = 'none';
				return;
		}
			
		var favNum = 0;
		var noteNum = 0;
		var errorNum = 0;
		var userID = G_Cookie.getUserID();
		var cptID = obj.id;
		G_Cookie.setCptID(cptID);
		if(userID) {
			var data = getNumber(userID, cptID);
			if(data) {
				favNum = data.favNum;
				noteNum = data.noteNum;
				errorNum = data.wrongTestNum;
			}
		}
		var father = obj.parentNode;
		var liTag = document.createElement('li');
		liTag.id = obj.id + '/liTag';
		liTag.className = 'choose_bg';
		var redo = document.createElement('div');
		redo.className = 'redo';
		redo.innerHTML = '重做本章';
		redo.onclick = function() {
			if(typeof(G_ChapterCache) !== 'undefined') {
			G_ChapterCache.removeCptIDInfo(Number(cptID));
		}
		var index = this.parentNode.previousSibling.id;
		var curMenu = G_cpmArrNodes[G_cpmArrNodes.length - 1];
		var cptName = curMenu[index].Name;
		G_UserAction.addUserAction('cptRedoBtn');
		window.location.href = 'doExam.html?fromUrl=yatiTest.html&myRedo=1&cptName=' + cptName;
		}
		var myErrorDiv = document.createElement('div');
		myErrorDiv.className = 'liTag_menu01';
		myErrorDiv.innerHTML = '错题(' + errorNum + ')';
		myErrorDiv.onclick = function() {
			G_UserAction.addUserAction('cptWrongBtn');
		myClick(this.parentNode, 'myError', errorNum);
		}
		var myfavDiv = document.createElement('div');
		myfavDiv.className = 'moer_menu02';
		myfavDiv.innerHTML = '收藏(' + favNum + ')';
		myfavDiv.onclick = function() {
			G_UserAction.addUserAction('cptFavBtn');
		myClick(this.parentNode, 'myFav', favNum);
		}
		var mynoteDiv = document.createElement('div');
		mynoteDiv.className = 'moer_menu02';
		mynoteDiv.innerHTML = '笔记(' + noteNum + ')';
		mynoteDiv.onclick = function() {
			G_UserAction.addUserAction('cptNoteBtn');
		myClick(this.parentNode, 'myNote', noteNum);
		}
		var notdoneDiv = document.createElement('div');
		notdoneDiv.className = 'moer_menu03';
		notdoneDiv.innerHTML = '未答(' + notDoneNum + ')';
		notdoneDiv.onclick = function() {
			G_UserAction.addUserAction('cptNoDoneBtn');
		myClick(this.parentNode, 'myNotDone', notDoneNum);
			}
			liTag.appendChild(redo);
			liTag.appendChild(notdoneDiv);
			liTag.appendChild(mynoteDiv);
			liTag.appendChild(myfavDiv);
			liTag.appendChild(myErrorDiv);
			insertAfter(liTag, father);
		}
		
	function myClick(obj, type, num) {
		var cptID = obj.id.split('/')[0];
		var index = obj.previousSibling.id;
		var curMenu = G_cpmArrNodes[G_cpmArrNodes.length - 1];
		var cptName = curMenu[index].Name;
		var userID = G_Cookie.getUserID();
		G_Cookie.setCptID(cptID);
		if(!userID) {
			var yesCallback = function() {
				window.location.href = 'login?fromUrl=ytmj';
		}
		G_Prg.confirm('该功能请登录后使用！', yesCallback);
			return;
		}
		if(type === 'myNotDone') {
		var arrData = [];
		var testCount = 0;
		if(userID && !IsVip) {
			arrData = G_cpmArrData;
			if(arrData) {
				for(var c = 0; c < arrData.length; c++) {
					if(parseInt(cptID) === parseInt(arrData[c].CptID)) {
						testCount = arrData[c].testCount;
						break;
					}
				}
				if(testCount === 5) {
					var yesCallback = function() {
						var isiphone = G_Prg.getCookie('CLIENTTYPE');
						if(isiphone && isiphone.toString().toLowerCase() === 'iphone') {
							window.location = "ios://iOSiap";
						} else {
							window.location.href = 'selectPrice.html?fromUrl=yatiTest.html';
						}
					}
					G_Prg.confirm('未购买用户只能做5道题，请购买再继续答题！', yesCallback);
					G_GoBuySoft.goBuySoft('未购买用户只能做5道题，请购买再继续答题！', 'selectPrice.html?fromUrl=yatiTest.html');
					return;
				}
				if(testCount > 5) {
					var yesCallback = function() {
						var isiphone = G_Prg.getCookie('CLIENTTYPE');
						if(isiphone && isiphone.toString().toLowerCase() === 'iphone') {
							window.location = "ios://iOSiap";
						} else {
							window.location.href = 'selectPrice.html?fromUrl=yatiTest.html';
						}
					}
					G_Prg.confirm('未购买用户只能做5道题，请续费再继续答题！', yesCallback);
					G_GoBuySoft.goBuySoft('未购买用户只能做5道题，请购买再继续答题！', 'selectPrice.html?fromUrl=yatiTest.html');
						return;
					}
				}
			}
		}
		if(num === 0) {
			switch(type) {
				case 'myFav':
				G_Prg.alert('无收藏记录');
				break;
			case 'myNote':
				G_Prg.alert('无笔记记录');
				break;
			case 'myError':
				G_Prg.alert('无错题记录');
				break;
			case 'myNotDone':
				G_Prg.alert('无未答题记录');
				break;
			default:
				G_Prg.throw('程序运行错误，chapterMenu.myClick ,不能处理type=' + type);
					break;
			}
			return;
		}
		var url = 'doExam.html?fromUrl=yatiTest.html&type=' + type + '&cptName=' + cptName + '&testNum=' + num;
			pageJump(url);
		}
	
		function getNumber(userID, cptID) {
			var appID = G_Cookie.getAppID();
			if(!appID) {
				G_Prg.throw('程序运行错误，chapterMenu.getNumber ,不能处理appID=' + appID);
		}
		var userName = G_Cookie.getUserName();
		if(!userName) {
			G_Prg.throw('程序运行错误，chapterMenu.getNumber ,不能处理userName=' + userName);
		}
		var data = '';
		var URL = '/api/analysis/getUserTestNumApi/X?appID=' + appID + '&&cptID=' + cptID + '&&guid=' + G_Cookie.getGuid();
		var success = function(json) {
			var jsonData = JSON.parse(json);
			if(jsonData.status === 200) {
				data = jsonData.data;
			} else if(jsonData.status === 201) {
				data = '';
		} else if(jsonData.status === 300) {
			G_Prg.throw('程序运行错误！："' + jsonData.msg + '"！');
		} else if(jsonData.status >= 400 && jsonData.status < 500) {
		} else {
			G_Prg.throw('程序运行错误！："无法处理"！');
				}
			};
			G_AjaxApi_Record.get(URL, false, success);
			return data;
		}
		
		function pageJump(url) {
			G_Prg.$('loadingDiv').style.display = 'block';
			G_Prg.$('Source_last').style.display = 'none';
			window.location.href = url;
		}
});
